﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeBehind="AddList_Unpaid.aspx.cs" Inherits="UdrinkWater_Project.Officer.AddList_Unpaid" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxFormLayout" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script type="text/javascript">
         function ProcessKeyPress(s, evt) {
             var charCode = (evt.htmlEvent.which) ? evt.htmlEvent.which : event.keyCode
             if (charCode > 31 && (charCode < 46 || charCode > 57))
                 _aspxPreventEvent(evt.htmlEvent);

         }
</script>
<script type="text/javascript">
    // <![CDATA[
    function ShowLoginWindow() {
        pcLogin.Show();
    }
    // ]]> 
    </script>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" 
        HeaderText="สร้างรายการค้างชำระ" Width="100%">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
    <dx:ASPxFormLayout ID="ASPxFormLayout1" runat="server" EnableTheming="True" 
        Theme="Youthful">
        <Items>
            <dx:LayoutGroup Caption="รายการค้างชำระ" Width="400px">
                <GroupBoxStyle>
                    <Caption BackColor="#E5EECF">
                    </Caption>
                </GroupBoxStyle>
                <Items>
                    <dx:LayoutGroup Caption="เลขที่ใบเสร็จอ้างอิง" ShowCaption="False">
                        <Items>
                            <dx:LayoutItem Caption="เลือกใบเสร็จอ้างอิง">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server" 
                                        SupportsDisabledAttribute="True">
                                        <dx:ASPxButton ID="bt_AddReferent" runat="server" Text="เลือก..">
                                            <ClientSideEvents Click="function(s, e) { ShowLoginWindow(); }" />
                                        </dx:ASPxButton>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="ใบเสร็จอ้างอิง">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server" 
                                        SupportsDisabledAttribute="True">
                                        <dx:ASPxTextBox ID="txt_Referent" runat="server" Width="170px" ReadOnly="True">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                        </Items>
                    </dx:LayoutGroup>
                    <dx:LayoutItem Caption="ชื่อ - นามสกุล">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxTextBox ID="txt_Name" runat="server" Width="170px">
                                </dx:ASPxTextBox>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                    <dx:LayoutItem Caption="ที่อยู่">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxTextBox ID="txt_Address" runat="server" Width="170px">
                                </dx:ASPxTextBox>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                    <dx:LayoutItem Caption="จังหวัด">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxComboBox ID="Com_Province" runat="server" TextField="PROVINCE_NAME" 
                                    ValueField="PROVINCE_ID" ValueType="System.Int32" AutoPostBack="True" 
                                    DataSourceID="SqlData_Province" 
                                    OnSelectedIndexChanged="Com_Province_SelectedIndexChanged">
                                </dx:ASPxComboBox>
                                <asp:SqlDataSource ID="SqlData_Province" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                    SelectCommand="SELECT * FROM [TB_Province]"></asp:SqlDataSource>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                    <dx:LayoutItem Caption="อำเภอ">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxComboBox ID="Com_Aumphur" runat="server" 
                                    TextField="AMPHUR_NAME" ValueField="AMPHUR_ID" ValueType="System.Int32" 
                                    AutoPostBack="True" DataSourceID="SqlData_Aumphur" 
                                    OnSelectedIndexChanged="Com_Aumphur_SelectedIndexChanged">
                                </dx:ASPxComboBox>
                                <asp:SqlDataSource ID="SqlData_Aumphur" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                    
                                    SelectCommand="SELECT * FROM [TB_Aumphur] WHERE ([PROVINCE_ID] = @PROVINCE_ID)">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="Com_Province" Name="PROVINCE_ID" 
                                            PropertyName="Value" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                    <dx:LayoutItem Caption="ตำบล">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxComboBox ID="Com_District" runat="server" TextField="DISTRICT_NAME" 
                                    ValueField="DISTRICT_ID" ValueType="System.Int32" 
                                    DataSourceID="SqlData_District">
                                </dx:ASPxComboBox>
                                <asp:SqlDataSource ID="SqlData_District" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                    
                                    SelectCommand="SELECT * FROM [TB_District] WHERE ([AMPHUR_ID] = @AMPHUR_ID)">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="Com_Aumphur" Name="AMPHUR_ID" 
                                            PropertyName="Value" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                    <dx:LayoutItem Caption="จำนวนค้างชำระ">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxTextBox ID="txt_Count" runat="server" Width="170px">
                                     <ClientSideEvents KeyPress="function(s,e) {
                    ProcessKeyPress(s, e);
                }" /> 
                                </dx:ASPxTextBox>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                    <dx:LayoutItem Caption="วันกำหนดค้างชำระ">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer runat="server" 
                                SupportsDisabledAttribute="True">
                                <dx:ASPxDateEdit ID="DateEdit_Deadline" runat="server">
                                </dx:ASPxDateEdit>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
                </Items>
            </dx:LayoutGroup>
        </Items>
    </dx:ASPxFormLayout>
    <div>
        
        <table style="width: 100%">
            <tr>
                <td align="right" style="width: 207px">
                    <dx:ASPxButton ID="bt_SaveUnpaid" runat="server" Text="บันทึกรายการ" 
                        OnClick="bt_SaveUnpaid_Click">
                         <ClientSideEvents Click="function(s, e) {
	e.processOnServer = confirm('ยืนยันการทำรายการค้างชำระ');
}" />
                    </dx:ASPxButton>
                </td>
                <td>
                    <dx:ASPxButton ID="bt_Cancel" runat="server" Text="ยกเลิก" 
                        OnClick="bt_Cancel_Click">
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>
    </div>
            </dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
    <dx:ASPxPopupControl ID="pcLogin" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcLogin"
        HeaderText="รายการ" AllowDragging="True" 
        PopupAnimationType="None" EnableViewState="False" Font-Size="16px" 
        Width="1200px">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent1" runat="server">
                            <dx:ASPxGridView ID="GV_ShowOrder" runat="server" AutoGenerateColumns="False" 
                                DataSourceID="SqlData_ShowOrder" KeyFieldName="Order_Date" 
                                OnRowCommand="ASPxGridView1_RowCommand" Width="100%">
                                <Columns>
                                    <dx:GridViewDataDateColumn FieldName="Order_Date" ReadOnly="True" 
                                        ShowInCustomizationForm="True" UnboundType="DateTime" VisibleIndex="1" 
                                        Caption="เลขที่ใบรายการ">
                                        <PropertiesDateEdit DisplayFormatString="dd-MM-yyyy HH:mm:ss.fff" 
                                            EditFormat="DateTime">
                                        </PropertiesDateEdit>
                                    </dx:GridViewDataDateColumn>
                                    <dx:GridViewDataTextColumn FieldName="Customer_ID" 
                                        ShowInCustomizationForm="True" VisibleIndex="2" Caption="ลูกค้า">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataDateColumn FieldName="Shipped_date" 
                                        ShowInCustomizationForm="True" VisibleIndex="3" Caption="วันส่งสินค้า">
                                    </dx:GridViewDataDateColumn>
                                    <dx:GridViewDataTextColumn FieldName="Delivery_Address" 
                                        ShowInCustomizationForm="True" VisibleIndex="4" Caption="ที่อยู่">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataComboBoxColumn FieldName="District_ID" 
                                        ShowInCustomizationForm="True" VisibleIndex="5" Caption="ตำบล">
                                        <PropertiesComboBox DataSourceID="Sql_District" TextField="DISTRICT_NAME" 
                                            ValueField="DISTRICT_ID" ValueType="System.Int32">
                                        </PropertiesComboBox>
                                    </dx:GridViewDataComboBoxColumn>
                                    <dx:GridViewDataComboBoxColumn FieldName="Aumphur_ID" 
                                        ShowInCustomizationForm="True" VisibleIndex="6" Caption="อำเภอ">
                                        <PropertiesComboBox DataSourceID="Sql_Aumphur" TextField="AMPHUR_NAME" 
                                            ValueField="AMPHUR_ID" ValueType="System.Int32">
                                        </PropertiesComboBox>
                                    </dx:GridViewDataComboBoxColumn>
                                    <dx:GridViewDataComboBoxColumn FieldName="Province_ID" 
                                        ShowInCustomizationForm="True" VisibleIndex="7" Caption="จังหวัด">
                                        <PropertiesComboBox DataSourceID="Sql_Province" TextField="PROVINCE_NAME" 
                                            ValueField="PROVINCE_ID" ValueType="System.Int32">
                                        </PropertiesComboBox>
                                    </dx:GridViewDataComboBoxColumn>
                                    <dx:GridViewDataComboBoxColumn FieldName="Employee_ID" 
                                        ShowInCustomizationForm="True" VisibleIndex="8" Caption="พนักงานทำรายการ">
                                        <PropertiesComboBox DataSourceID="Sql_Employee" TextField="ID_Card" 
                                            ValueField="ID_Card">
                                        </PropertiesComboBox>
                                    </dx:GridViewDataComboBoxColumn>
                                    <dx:GridViewDataComboBoxColumn FieldName="Status" 
                                        ShowInCustomizationForm="True" VisibleIndex="9" Caption="สถานะการส่ง">
                                        <PropertiesComboBox DataSourceID="Sql_Status" TextField="Status_Name" 
                                            ValueField="Status_ID" ValueType="System.Int32">
                                        </PropertiesComboBox>
                                    </dx:GridViewDataComboBoxColumn>
                                    <dx:GridViewDataTextColumn ShowInCustomizationForm="True" VisibleIndex="10">
                                        <DataItemTemplate>
                                            <asp:LinkButton ID="Link_Detail" CommandName="Cmd_Add" runat="server" 
                                               >เลือกรายการ
                                            </asp:LinkButton>
                                        </DataItemTemplate>
                                    </dx:GridViewDataTextColumn>
                                </Columns>
                            </dx:ASPxGridView>
                            <asp:SqlDataSource ID="SqlData_ShowOrder" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                
                                SelectCommand="SELECT [Order_Date], [Customer_ID], [Shipped_date], [Delivery_Address], [District_ID], [Aumphur_ID], [Province_ID], [Employee_ID], [Status] FROM [TB_Order] WHERE ([Status] = @Status)">
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="2" Name="Status" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            <asp:SqlDataSource ID="Sql_Province" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                SelectCommand="SELECT * FROM [TB_Province]"></asp:SqlDataSource>
                            <asp:SqlDataSource ID="Sql_Aumphur" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                SelectCommand="SELECT * FROM [TB_Aumphur]"></asp:SqlDataSource>
                            <asp:SqlDataSource ID="Sql_District" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                SelectCommand="SELECT * FROM [TB_District]"></asp:SqlDataSource>
                            <asp:SqlDataSource ID="Sql_Status" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                SelectCommand="SELECT * FROM [TB_SenderStatus]"></asp:SqlDataSource>
                            <asp:SqlDataSource ID="Sql_Employee" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                SelectCommand="SELECT [ID_Card] FROM [TB_Employee]"></asp:SqlDataSource>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <div>
                    &nbsp;</div>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ContentStyle>
            <Paddings PaddingBottom="5px" />
        </ContentStyle>
    </dx:ASPxPopupControl>
</asp:Content>
